/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.solaris;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;

/**
 *
 * @author Frank
 */
public class Network {
    
    private static Network network = null;
    
    protected Network() {
        // We schakelen constructor uit voor singleton doeleinden
    }
    
    public static Network instantiate() {
        if(network == null) {
            network = new Network();
        }
        return network;
    }

    public boolean checkInternetConnection(Activity activity) {
        
        // Om te kunnen testen of er internet is halen we de connectie op uit de activity
        ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
        
        // Test of er internet is
        if (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isAvailable() && cm.getActiveNetworkInfo().isConnected()) {
            return true;
        } 
        
        return false;
        
    }
    
}
